package com.util;

import com.dao.Flight;

import java.sql.Time;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Phillip on 2014/4/26.
 */
public class Transformer {

    public static List<Flight> c2d(corba.airlineServer.Flight[] cFlights) {

        List<Flight> flightList = new ArrayList<>();
        for (int i = 0; i < cFlights.length; i++) {
            Flight tempFlight = new Flight();
            tempFlight.setAirlineString(cFlights[i].airline);
            tempFlight.setArriAirportString(cFlights[i].arriAirport);
            tempFlight.setArriTime(Time.valueOf(cFlights[i].arriTime));
            tempFlight.setClassEnum(cFlights[i].seatClass);
            tempFlight.setDeptAirportString(cFlights[i].deptAirport);
            tempFlight.setDeptCityString(cFlights[i].deptCity);
            tempFlight.setDeptTime(Time.valueOf(cFlights[i].deptTime));
            tempFlight.setDestCityString(cFlights[i].destCity);
            tempFlight.setFligthNOString(cFlights[i].flightNumber);
            tempFlight.setPlaneString(cFlights[i].plane);
            tempFlight.setPriceString(cFlights[i].price);

            flightList.add(tempFlight);
        }
        return flightList;
    }
}
